<template>
	<view class="height-100 bg-or">
		<view class="flex-direction-row justify-between padding bg-white">
			<text class="text-smd color-df">NO.{{details.prescriptionCode}}</text>
			<text class="text-sm color-black-q">{{details.prescriptionCondition?.createTime}}</text>
		</view>
		<!-- 患者资料 -->
		<view class="bg-white radius-xl padding margin">
			<view class="flex-direction-row justify-between">
				<view class="">
					<text class="text-df text-bold">患者：</text>
					<text class="text-df color-black-q">{{details.prescriptionCondition?.prescriptionPatient?.name}}</text>
				</view>
				<view class="">
					<text class="text-df text-bold">性别：</text>
					<text class="text-df color-black-q">{{details.prescriptionCondition?.prescriptionPatient?.gender === 0 ? '男' : '女'}}</text>
				</view>
				<view class="">
					<text class="text-df text-bold">年龄：</text>
					<text class="text-df color-black-q">{{details.prescriptionCondition?.prescriptionPatient?.age}}</text>
				</view>
			</view>
			<view class="border-top margin-top padding-tb flex-direction-column">
				<text class="text-df color-green">初步诊断</text>
				<text class="text-df margin-top-sm">{{details.primaryDiagnosis}}</text>
				<text class="text-df color-green margin-top">处理意见</text>
				<text class="text-df margin-top-sm">{{details.processAdvice}}</text>
			</view>
		</view>
		<!-- 配药 -->
		<view class="bg-white radius-xl padding margin">
			<view class="padding-tb">
				<text class="text-lg color-df">配药</text>
			</view>
			<block v-for='(item,index) in details.prescriptionProductItemList' :key='index'>
				<view class="flex-direction-column padding-tb border-top">
					<view class="flex-direction-row justify-between">
						<text class="text-df text-bold">{{item.productName}}</text>
						<text class="text-sm color-black-q">x {{item.count}}</text>
					</view>
					<text class="text-smd color-black-q margin-top-xsm">规格：{{item.productSpaceName}}</text>
					<text
						class="text-smd color-black-b margin-top-xsm">{{medicationUsageArray[item.medicationUsage]}}：{{usageFrequencyArray[item.usageFrequency]}} {{unitArray[item.unit]}}</text>
				</view>
			</block>
		</view>
		<!--  -->
		<view class="bg-white radius-xl padding margin">
			<view class="">
				<text class="text-df text-bold">处方医师：</text>
				<text class="text-sm color-black-q">{{details.prescriptionPhysicianName}}</text>
			</view>
			<view class="margin-top">
				<text class="text-df text-bold">科室：</text>
				<text class="text-sm color-black-q">{{details.department}}</text>
			</view>
		</view>
		<!-- 查看原始处方 -->
		<!-- <template v-if="details.prescriptionCondition?.patientImage">
			<view class="border-df padding-lr-xl padding-tb-sm radius-sl"
				@click="$navigator('/pages/prescription/original?patientImage='+details.prescriptionCondition?.patientImage)">
				<text class="text-df color-df">查看原始处方</text>
			</view>
		</template> -->
	</view>
</template>

<script>
	import {
		fields
	} from "@/common/fields.js"
	export default {
		onLoad(option) {
			if (option.id) {
				this.optionId = option.id
				// 获取处方基本信息
				this.getDetail();
			}
		},
		data() {
			return {
				details:{},
				usageFrequencyArray: fields.usageFrequency,
				unitArray: fields.unit,
				medicationUsageArray: fields.medicationUsage,
			}
		},
		methods: {
			async getDetail() {
				const res = await uni.$request.get('/doctorPrescriptionApi/' + this.optionId, {});
				console.log('getDetail res: ', res.data);
				if (res.code === 200) {
					this.details = res.data;
				} else {
					uni.showModal({
						title: '提示',
						content: '数据查询失败',
						showCancel: false
					});
				}
			},
		}
	}
</script>

<style>

</style>
